package appConfig

import (
	"github.com/spf13/viper"
	"log"
)

type AppConfig struct {
	Mysql
	Redis
}

type Mysql struct {
	User     string
	Password string
	Host     string
	Port     int
	Database string
}

type Redis struct {
	Adds     string
	Password string
}

var ConfigData AppConfig

func Init() {
	viper.SetConfigFile("../appConfig/config.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		log.Println("文件读取失败")
	}
	err = viper.Unmarshal(&ConfigData)
	if err != nil {
		log.Println("文件解析失败")
	}
	log.Println(ConfigData)
}
